package com.example.app1

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import android.view.View

class RoundView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {

    private val bitmap = getBitmap(resources, R.drawable.abc)
    private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
    private val path = Path()

    override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
        super.onSizeChanged(w, h, oldw, oldh)
        path.addCircle(width / 2f, height / 2f, 100.dp, Path.Direction.CCW)
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        canvas.clipPath(path)
        canvas.drawBitmap(bitmap, width / 2f - 100.dp, height / 2f - 100.dp, paint)
    }
}